import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    dataIndex: 'ph'
   },
   {
    title: '工程名称',
    align:"center",
    dataIndex: 'gcmc'
   },
   {
    title: '工程队名称',
    align:"center",
    dataIndex: 'gcName'
   },
   {
    title: '工程类型',
    align:"center",
    dataIndex: 'gclx_dictText'
   },
   {
    title: '预算造价',
    align:"center",
    dataIndex: 'ysp'
   },
   {
    title: '支付比例',
    align:"center",
    dataIndex: 'zfb'
   },
   {
    title: '维修比例',
    align:"center",
    dataIndex: 'wxl'
   },
   {
    title: '进场金额',
    align:"center",
    dataIndex: 'jcp'
   },
   {
    title: '签订日期',
    align:"center",
    dataIndex: 'gcDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '是否补充合同',
    align:"center",
    dataIndex: 'dhtSta',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}])
     },
   },
   {
    title: '主合同编号',
    align:"center",
    dataIndex: 'mph'
   },
   {
    title: '结算金额',
    align:"center",
    dataIndex: 'jsp'
   },
   {
    title: '结算日期',
    align:"center",
    dataIndex: 'jspDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '说明',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '合同文件',
    align:"center",
    dataIndex: 'flname',
    slots: { customRender: 'flnameSlot' },
   },
/*   {
    title: 'stxt',
    align:"center",
    dataIndex: 'stxtString'
   },*/
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "工程名称",
      field: 'gcmc',
      component: 'JInput',
      colProps: {span: 6},
 	},
     {
      label: "签订日期",
      field: "gcDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      colProps: {span: 6},
	},
     {
      label: "结算日期",
      field: "jspDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!'},
          ];
     },
  },
  {
    label: '工程名称',
    field: 'gcmc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工程名称!'},
          ];
     },
  },
  {
    label: '工程队名称',
    field: 'gcName',
    component: 'JSearchSelect',
    componentProps:{
      dict:"DB_GCB,GC_NAME,GC_NAME"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工程队名称!'},
          ];
     },
  },
  {
    label: '工程类型',
    field: 'gclx',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"construction_type"
     },
  },
  {
    label: '预算造价',
    field: 'ysp',
    defaultValue: 0,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入预算造价!'},
          ];
     },
  },
  {
    label: '支付比例',
    field: 'zfb',
    defaultValue: 1,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入支付比例!'},
          ];
     },
  },
  {
    label: '维修比例',
    field: 'wxl',
    defaultValue: 0,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入维修比例!'},
          ];
     },
  },
  {
    label: '进场金额',
    field: 'jcp',
    defaultValue: 0,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入进场金额!'},
          ];
     },
  },
  {
    label: '签订日期',
    field: 'gcDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入签订日期!'},
          ];
     },
  },
  {
    label: '是否补充合同',
    field: 'dhtSta',
    defaultValue: "0",
     component: 'JSwitch',
     componentProps:{
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否补充合同!'},
          ];
     },
  },
  {
    label: '主合同编号',
    field: 'mph',
    component: 'Input',
  },
  {
    label: '结算金额',
    field: 'jsp',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入结算金额!'},
          ];
     },
  },
  {
    label: '结算日期',
    field: 'jspDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入结算日期!'},
          ];
     },
  },
  {
    label: '说明',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '合同文件',
    field: 'flname',
    component: 'JUpload',
    helpMessage: '最多上传5个文件',
    componentProps: {
      maxCount: 5,
      bizPath: 'gcht'
    },
  },
/*  {
    label: 'stxt',
    field: 'stxtString',
    component: 'Input',
  },*/
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
